home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Libraries
/
SAT 2.3.8
/
Demos
/
HeartQuest demo ƒ
/
sBonus.p
< prev
next >
Wrap
Text File
|
1995-01-16
|
2KB
|
97 lines
{===============================================}
{================= Bonus sprite unit ================}
{===============================================}
{ Example file for Ingemars Sprite Animation Toolkit. }
{ © Ingemar Ragnemalm 1992 }
{ See doc files for legal terms for using this code. }
unit sBonus;
{ Sprite unit. A sprite unit should include the following routines:}
{ Init-procedure, that initializes private bitmaps}
{ Setup-procedure, that sets variables other than the standard ones set by MakeSprite }
{ Handle-procedure, to be called once per iteration until the sprite dies }
{ Hittask-procedure (optional), for advanced collission handling. }
interface
uses
{$IFC UNDEFINED THINK_PASCAL}
Types, Quickdraw,
{$ENDC}
SAT, sPoints, scores, SoundConst, GameGlobals;
procedure InitBonus;
procedure SetupBonus (mp: SpritePtr);
procedure HandleBonus (me: SpritePtr);
implementation
var
BonusFace: array[1..3] of FacePtr;
procedure InitBonus;
var
ii: integer;
h: handle;
begin
for ii := 1 to 3 do
begin
BonusFace[ii] := SATGetFace(127 + ii);
end;
end;
procedure SetupBonus (mp: SpritePtr);
var
i: integer;
begin
i := SATRand(3) + 1;
mp^.face := BonusFace[i];
{mp^.mask := Bonusmask[i];}
if mp^.position.h < 300 then
mp^.speed.h := 5
else
mp^.speed.h := -5;
SetRect(mp^.hotRect, -13 + 16, -28 + 32, 13 + 16, 0 + 32);
mp^.task := @HandleBonus;
end;
procedure HandleBonus (me: SpritePtr);
var
mp: Spriteptr;
begin
if me^.kind <> -4 then
begin
me^.task := nil; { Caught by the player! }
AddScore(50);
mp := SATNewSprite(0, me^.position.h, me^.position.v, @SetupPoints);
SATSoundPlay(jaSndH, 5, true);
bonusesCollected := bonusesCollected + 1;
end
else
begin
bonusObjectRunning := true;
if not features^^.macho then
levelCompleted := false;
end;
me^.mode := me^.mode + 1;
me^.position.h := me^.position.h + me^.speed.h;
if me^.position.h > gSAT.offSizeH then
begin
me^.task := nil;
{bonusLevelWanted := false; {Missed the bonus!}
end;
if me^.position.h < -32 then
begin
me^.task := nil;
{bonusLevelWanted := false; {Missed the bonus!}
end;
end;
end.